<?php

namespace app\admin\service\statistics\promotion\h5;

use app\admin\service\statistics\promotion\AbstractComputeStatistician;
use app\admin\service\statistics\traits\CompletionTrait;
use function show_percentage;

/**
 * 渠道数据 H5 问答数 用户未点补充信息的是问答
 * Class LoginRegisterRate
 * @package app\admin\service\statistics\promotion
 */
class WendaCount extends AbstractComputeStatistician
{
    // 补齐
    use CompletionTrait;

    // new_member_count,captcha_count
    protected function compute(int $index)
    {
        $statisticians = $this->statisticians;

        $lawsuit_count0 = $statisticians['h5-lawsuit_count0'][$index]['value'] ?? null;

        $landing_count0 = $statisticians['h5-landing_count0'][$index]['value'] ?? null;

        if (!is_numeric($lawsuit_count0) && !is_numeric($landing_count0)) {
            return '';
        }

        if(!is_numeric($lawsuit_count0)){
            $lawsuit_count0 = 0;
        }

        if(!is_numeric($landing_count0)){
            $landing_count0 = 0;
        }

        return $lawsuit_count0 + $landing_count0;
    }

    protected function getDefaultValue()
    {
        return '0';
    }
}